<template>
	<view class="ShopList">
		<view class="list">
			<view class="item" v-for="(item,index) in shoplist" :key="index">
				<view class="left">
					<image v-if="item.img" :src="item.img | getImg" mode=""></image>
					<image v-else src="/static/img/logo.png" mode=""></image>
					<view class="info">
						<view class="title">
							{{item.shop_name}}
						</view>
						<view class="phone">
							商家手机号：{{item.phone}}
						</view>

					</view>
				</view>
				<view class="right" @click="toDetail(item.id,1)" v-if="item.status == 1">
					<text>审核通过</text>
					<text class="seemore">查看详情</text>
				</view>
				<view class="right" @click="toDetail(item.id,2)" v-else>
					<text>待审核</text>
					<text class="seemore">去审核</text>
				</view>
			</view>
		</view>
		<view class="no-list" v-if="shoplist.length == 0">
			<image src="/static/img/e.png" mode="widthFix"></image>
			<text>暂无数据</text>
		</view>
	</view>
</template>

<script>
	import {
		ShopDirect
	} from "@/api/user.js"
	export default {
		data() {
			return {
				shoplist: [],
				is_service: 0
			}
		},
		onLoad() {

		},
		onShow() {
			// this.ShopDirect()
		},
		methods: {
			ShopDirect() {
				ShopDirect().then(res => {
					console.log(res);
					this.shoplist = res.data.list
					this.is_service = res.data.is_service
				})
			},
			toDetail(id, type) {
				if (type == 1) {
					uni.navigateTo({
						url: 'shopitem/shopitem?type=detail&id=' + id
					})
				} else {
					if (this.is_service == 0) {
						uni.showToast({
							title: '您还不是服务中心身份',
							icon: "none"
						})
					} else if (this.is_service == 1) {
						uni.navigateTo({
							url: 'shopitem/shopitem?type=edit&id=' + id
						})
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #0F172A;
		padding-top: 10px;
	}

	.item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 10px;
		font-size: 14px;
		background: #1E293B;
		color: #fff;
		width: 96%;
		margin: 0 auto;
		border-radius: 8px;
		margin-bottom: 10px;
		box-sizing: border-box;

		.left {
			display: flex;
			align-items: center;

			image {
				width: 50px;
				border-radius: 50%;
				height: 50px;
			}

			.info {
				padding-left: 8px;
				color: #fff;

				.title {
					font-size: 14px;
				}

				.phone {
					font-size: 12px;
					margin-top: 10px;
				}
			}
		}

		.right {
			display: flex;
			flex-direction: column;
			align-items: center;
			font-size: 12px;

			.seemore {
				background: #263249;
				padding: 5px;
				border-radius: 5px;
				margin-top: 5px;
				color: #798AD6;
			}
		}
	}
</style>